<?php

class MoninputHelper extends AppHelper{

	function deleteInverse($libelle, $id, $page, $message) {

		if (is_array($id)){
			$seq='';
			foreach ($id as $i){
				$seq=$seq.'/'.$i;
			}
		}else{
			$seq='/'.$id;
		}

		$hash=hash('md5', $page.'_'.$seq);

		return $this->output(        
			'<a href="#" class="btn btn-danger btn-small" onclick="if (confirm(&#039;'.$message.'&#039;)) 
									{ 
										document.post_'.$hash.'.submit(); 
									} 
								event.returnValue = false; 
								return false;">
				<i class="icon-trash icon-white"></i>
				'.str_pad('Delete', 20, " ", STR_PAD_BOTH).'
			</a>
			<form action="'.$this->request->webroot.mb_strtolower ($page).'/delete'.$seq.'" name="post_'.$hash.'" id="post_'.$hash.'" style="display:none;" method="post">
				<input type="hidden" name="_method" value="POST"/>
			</form>'
		);
	}

	function delete($libelle, $id, $page, $message) {

		if (is_array($id)){
			$seq='';
			foreach ($id as $i){
				$seq=$seq.'/'.$i;
			}
		}else{
			$seq='/'.$id;
		}

		$hash=hash('md5', $page.'_'.$seq);

		return $this->output(    
			'<form action="'.$this->request->webroot.mb_strtolower ($page).'/delete'.$seq.'" name="post_'.$hash.'" id="post_'.$hash.'" style="display:none;" method="post">
				<input type="hidden" name="_method" value="POST"/>
			</form>
			<a href="#" class="btn btn-danger btn-mini" onclick="if (confirm(&#039;'.$message.'&#039;)) 
									{ 
										document.post_'.$hash.'.submit(); 
									} 
								event.returnValue = false; 
								return false;">
				<i class="icon-trash icon-white"></i>'
				//'.str_pad('Delete', 20, " ", STR_PAD_BOTH).
				.'</a>'
		);
	}

} 